package com.example.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.admin.entity.SysMenu;
import com.example.admin.entity.SysRole;
import com.example.admin.entity.SysUser;
import com.example.admin.mapper.SysMenuMapper;
import com.example.admin.mapper.SysRoleMapper;
import com.example.admin.mapper.SysUserMapper;
import com.example.admin.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class DashboardServiceImpl implements DashboardService {

    @Autowired
    private SysUserMapper userMapper;
    
    @Autowired
    private SysRoleMapper roleMapper;
    
    @Autowired
    private SysMenuMapper menuMapper;

    @Override
    public Map<String, Integer> getStatistics() {
        Map<String, Integer> statistics = new HashMap<>();
        
        // 获取用户总数
        statistics.put("userCount", userMapper.selectCount(null));
        
        // 获取角色总数
        statistics.put("roleCount", roleMapper.selectCount(null));
        
        // 获取菜单总数
        statistics.put("menuCount", menuMapper.selectCount(null));
        
        // 在线用户数(示例数据)
        statistics.put("onlineCount", 1);
        
        return statistics;
    }
} 